home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / tool-inc.zip / SYSDATE0.INC < prev    next >
Text File  |  1989-06-02  |  1KB  |  54 lines

  1.  
  2. (*
  3.  * Copyright 1987, 1989 Samuel H. Smith;  All rights reserved
  4.  *
  5.  * This is a component of the ProDoor System.
  6.  * Do not distribute modified versions without my permission.
  7.  * Do not remove or alter this notice or any other copyright notice.
  8.  * If you use this in your own program you must distribute source code.
  9.  * Do not use any of this in a commercial product.
  10.  *
  11.  *)
  12.  
  13. (*
  14.  * sysdate - library to return system date and time (3-1-89)
  15.  *
  16.  *)
  17.  
  18. function system_date: string20;
  19. const
  20.    month : array [1..12] of string[3]
  21.            = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
  22.               'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
  23. var
  24.    reg:           registers;
  25.  
  26.    function strval (i: integer): string2;
  27.    begin
  28.       strval := chr(((i div 10) mod 10) + ord('0')) +
  29.                 chr((i mod 10) + ord('0'));
  30.    end;
  31.  
  32. begin
  33.    reg.ax := $2a00;
  34.    msdos(reg);
  35.    system_date := strval(lo(reg.dx)) + '-' +
  36.                   month[hi(reg.dx)] + '-' +
  37.                   strval(reg.cx-1900);
  38. end;
  39.  
  40.  
  41. function system_time: string10;
  42. var
  43.    reg:       registers;
  44.    hh,mm,ss:  string[2];
  45.  
  46. begin
  47.    reg.ax := $2c00;
  48.    msdos(reg);
  49.    str(hi(reg.cx),hh);  if length(hh) = 1 then hh := '0' + hh;
  50.    str(lo(reg.cx),mm);  if length(mm) = 1 then mm := '0' + mm;
  51.    str(hi(reg.dx),ss);  if length(ss) = 1 then ss := '0' + ss;
  52.    system_time := hh + ':' + mm + ':' + ss;
  53. end;
  54.